
//
// 130419 - AH - Created.
// 130609 - AH - validate methods can now return an object that is result of
//               parsing.
//

package org.japril.servlet.xmlservlet;

import java.io.IOException;
import java.io.InputStream;

/**
 * <p>
 *   Interface for object that validates XML received.
 * </p>
 * @author Arne Halvorsen (AH)
 */
public interface XmlValidator 
{
  /**
   * <p>
   *   Validate XML.
   * </p>
   * @param is {@link InputStream} to read XML from.
   * @return An object being the result of the parse, may be {@code null}.
   * @throws IOException If failed to read or validate.
   */
  Object validate(InputStream is) throws IOException;
  
  /**
   * <p>
   *   Validate XML.
   * </p>
   * @param xml XML to validate.
   * @return An object being the result of the parse, may be {@code null}. 
   * @throws IOException If failed to read or validate.
   */
  //Object validate(String xml) throws IOException;
  void validate(String xml) throws IOException;
  
  /**
   * <p>
   *   Validator may hold some attributes after validated XML which this method
   *   can fetch value of.
   * </p>
   * @param name Attribute name.
   * @return Value or {@code null} if not found.
   */
  String getAttribute(String name);
  
}
